import * as React from 'react';
import { Autocomplete, AutocompleteProps } from '@aws-amplify/ui-react';
import { useAutocompleteProps } from './useAutocompleteProps';
import { AutocompletePropControls } from './AutocompletePropControls';
import { Demo } from '@/components/Demo';
import { demoState } from '@/utils/demoState';
const propsToCode = (autocompleteProps: AutocompleteProps) => {
return (
``
);
};
const options = [
{ id: 'apple', label: 'apple' },
{ id: 'banana', label: 'banana' },
{ id: 'cherry', label: 'cherry' },
{ id: 'grape', label: 'grape' },
{ id: 'kiwis', label: 'kiwis' },
{ id: 'lemon', label: 'lemon' },
{ id: 'mango', label: 'mango' },
{ id: 'orange', label: 'orange' },
{ id: 'strawberry', label: 'strawberry' },
];
const defaultAutocompletedProps = {
isDisabled: false,
isLoading: false,
label: 'Autocomplete',
labelHidden: true,
options,
placeholder: 'Search here...',
size: null,
variation: null,
};
export const AutocompleteDemo = () => {
const autocompleteProps = useAutocompleteProps(
(demoState.get(Autocomplete.displayName) as AutocompleteProps) ||
defaultAutocompletedProps
);
const onSubmit = React.useCallback(
(value) => alert(`you searched for ${value}`),
[]
);
return (
}
>
);
};